package com.example.gty.service.Impl;

import com.example.gty.service.MailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Service;

@Service
public class MailServiceImpl implements MailService {
    @Autowired
    private JavaMailSenderImpl javaMailSender;
    @Value("${spring.mail.username}")
    private String from;//邮箱发送人

    //定制纯文本文件 发送
    //接收的邮箱号  标题 内容
    public void sendText(String to,  String text) {
        SimpleMailMessage simple = new SimpleMailMessage();
        simple.setFrom(from);
        simple.setSubject("修改个人信息验证");
        simple.setText(text);//邮箱发送信息
        simple.setTo(to);

        javaMailSender.send(simple);
        System.out.println("发送邮件");
    }
}
